/*
 * 查房列表
 * @author 醉雪
 * @time 2018/10/17
 * @since 1.0.0
 * */
// React基础组件
import React from 'react'
// dva 连接组件 - 连接route和model
import { connect } from 'dva'
// 引入antd的组件
import { Form, Select, Input, DatePicker, Button, Radio, Row, Col, Tooltip, Icon } from 'antd'
import moment from 'moment';
const { RangePicker } = DatePicker;
const dateFormat = 'YYYY/MM/DD';
//导入路由组件，用于跳转等
import { Link, hashHistory } from 'dva/router'
// 导入项目全局配置文件
import config from 'config/config'

// 引入model取值工具方法
import { mapStateToProps } from 'utils/view_utils'
// 当前组件样式
import styles from './editDistributionOfConsultantStyle.less'
import classnames from 'classnames/bind';
let cx = classnames.bind(styles);
//引用listPage
import ListPage from 'widget/PageTmpl/ListPage'
import UserPop from 'widget/UserPop/UserPop'
import { CollapsiblePanels } from 'widget/CollapsiblePanels/index'
const Option = Select.Option;
const FormItem = Form.Item;
const formItemLayout = {
  labelCol: {
    span: 12
  },
  wrapperCol: {
    span: 12
  },
}
/**
 * description 路由视图及事件处理
 * dispatch 分发到models中的effects对应事件名
 * model 用于获取models中state定义的数据
 * form 表单对象
 */

const infoListAdminView = function ({ dispatch, model, form }) {
  // 表单的子函数
  const { resetFields, getFieldDecorator, validateFields, setFieldsValue } = form
  // 取出model对象，命名空间
  const { modelObj, namespace } = model
  // modelObj.xxx获取model中状态机的值
  let { areaList, showAddVisible, projectList, createConsultantParams, type, isHasScore, lock, flagZeroId } = modelObj;
  //单选切换
  function onChangRadio(val, type, opt) {
    createConsultantParams[type] = val.target.value
    dispatch({
      type: `${namespace}/updateStore`,
      payload: {createConsultantParams}
    });
  }
  // 保存
  function sureAddConsultant(params) {
    dispatch({
      type: `${namespace}/addform`,
      payload: {createConsultantParams}
    });
  }
  return (
    <div className={cx('public_listMain')}>
      <div className="functionButton">
        {
          !lock && <div className={cx('sure')}>
            <Button type="primary" onClick={sureAddConsultant}>保存</Button>
          </div>
        }
      </div>

      <div className={'boxShadow'}>
        <div  >
          <Form autoComplete="off" className="auto-wrap">
            <Row>
              <Col span={11} offset={3} className="building_de_jinpai">
                <FormItem {...formItemLayout}
                  required={true}
                  label="楼盘详情金牌顾问分配规则"
                >
                    <Radio.Group onChange={(e) => onChangRadio(e, 'goldAdvisorAssignment')} value={createConsultantParams.goldAdvisorAssignment}>
                      <Radio value={'CARD_VISIT'}>按访问量分配</Radio>
                      <Radio value={'RANDOM'}>系统随机分配</Radio>
                    </Radio.Group>
                </FormItem>
              </Col>
              <Col span={1}>
                <span className={styles.marl14}>
                  <Tooltip
                    title={
                      <div>
                        <div>按访问量分配：</div>
                        <div>上月名片访问量前20%的置业顾问，有50%的几率；</div>
                        <div>上月名片访问量前30%的置业顾问，有30%的几率；</div>
                        <div>上月名片访问量后50%的置业顾问，有20%的几率；</div>
                      </div>

                    }
                  >
                    <Icon className={styles.iconTooltip} type="question-circle" />
                  </Tooltip>
                </span>
              </Col>
              <Col span={4}>
              <a className={styles.marl14} onClick={() => {
                  hashHistory.push({
                    pathname: '/home/realEstateConsultantAdmin/consultantAdmin',
                    query: {productName:createConsultantParams.productName, productId: createConsultantParams.productId}
                  })
                }}>查看顾问明细</a>
              </Col>
            </Row>

            <Row>
              <Col span={11} offset={3} className="building_de_jinpai">
                <FormItem {...formItemLayout}
                  required={true}
                  label="全民营销推荐客户分配规则"
                >
                    <Radio.Group onChange={(e) => onChangRadio(e, 'recommCustomerAssignment')} value={createConsultantParams.recommCustomerAssignment}>
                      <Radio value={'CARD_VISIT'}>按访问量分配</Radio>
                      <Radio value={'RANDOM'}>系统随机分配</Radio>
                    </Radio.Group>
                </FormItem>
              </Col>
              <Col span={1}>
                <span className={styles.marl14}>
                  <Tooltip
                    title={
                      <div>
                        <div>按访问量分配：</div>
                        <div>上月名片访问量前20%的置业顾问，有50%的几率；</div>
                        <div>上月名片访问量前30%的置业顾问，有30%的几率；</div>
                        <div>上月名片访问量后50%的置业顾问，有20%的几率；</div>
                      </div>

                    }
                  >
                    <Icon className={styles.iconTooltip} type="question-circle" />
                  </Tooltip>
                </span>
              </Col>
              <Col span={4}>
                <a className={styles.marl14} onClick={() => {
                  hashHistory.push({
                    pathname: '/home/realEstateConsultantAdmin/consultantAdmin',
                    query: {productName:createConsultantParams.productName, productId: createConsultantParams.productId}
                  })
                }}>查看顾问明细</a>
              </Col>
            </Row>
          </Form>
        </div>
      </div>
    </div>
  )
}

// 连接视图(view)和模型(model)
export default connect(mapStateToProps)(Form.create()(infoListAdminView))
